<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="com.example.dao.UserDao" %>
<%@ page import="com.example.util.DBUtil" %>
<%
    // 检查是否为POST请求
    if (!"POST".equalsIgnoreCase(request.getMethod())) {
        response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
        return;
    }

    request.setCharacterEncoding("UTF-8");
    
    try {
        int userId = Integer.parseInt(request.getParameter("id"));
        
        UserDao userDao = new UserDao();
        userDao.deleteUser(userId);
        
        response.sendRedirect("user_list.jsp?message=用户删除成功");
    } catch (NumberFormatException e) {
        response.sendRedirect("user_list.jsp?error=无效的用户ID");
    } catch (Exception e) {
        response.sendRedirect("user_list.jsp?error=删除用户失败: " + e.getMessage());
    }
%>